﻿using System;
using UnityEngine.UI;

namespace UniRx
{
	// Token: 0x02000414 RID: 1044
	public static class ReactiveCommandExtensions
	{
		// Token: 0x06001573 RID: 5491 RVA: 0x0005F4CB File Offset: 0x0005D8CB
		public static ReactiveCommand ToReactiveCommand(this IObservable<bool> canExecuteSource, bool initialValue = true)
		{
			return new ReactiveCommand(canExecuteSource, initialValue);
		}

		// Token: 0x06001574 RID: 5492 RVA: 0x0005F4D4 File Offset: 0x0005D8D4
		public static ReactiveCommand<T> ToReactiveCommand<T>(this IObservable<bool> canExecuteSource, bool initialValue = true)
		{
			return new ReactiveCommand<T>(canExecuteSource, initialValue);
		}

		// Token: 0x06001575 RID: 5493 RVA: 0x0005F4E0 File Offset: 0x0005D8E0
		public static IDisposable BindTo(this ReactiveCommand<Unit> command, Button button)
		{
			IDisposable disposable = command.CanExecute.SubscribeToInteractable(button);
			IDisposable disposable2 = button.OnClickAsObservable().SubscribeWithState(command, delegate(Unit x, ReactiveCommand<Unit> c)
			{
				c.Execute(x);
			});
			return StableCompositeDisposable.Create(disposable, disposable2);
		}

		// Token: 0x06001576 RID: 5494 RVA: 0x0005F52C File Offset: 0x0005D92C
		public static IDisposable BindToOnClick(this ReactiveCommand<Unit> command, Button button, Action<Unit> onClick)
		{
			IDisposable disposable = command.CanExecute.SubscribeToInteractable(button);
			IDisposable disposable2 = button.OnClickAsObservable().SubscribeWithState(command, delegate(Unit x, ReactiveCommand<Unit> c)
			{
				c.Execute(x);
			});
			IDisposable disposable3 = command.Subscribe(onClick);
			return StableCompositeDisposable.Create(disposable, disposable2, disposable3);
		}

		// Token: 0x06001577 RID: 5495 RVA: 0x0005F580 File Offset: 0x0005D980
		public static IDisposable BindToButtonOnClick(this IObservable<bool> canExecuteSource, Button button, Action<Unit> onClick, bool initialValue = true)
		{
			return canExecuteSource.ToReactiveCommand(initialValue).BindToOnClick(button, onClick);
		}
	}
}
